﻿using System;
using Scenario.WorkflowEngine;

namespace Scenario.Tools
{
    public class Executor
    {
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                System.Console.WriteLine("\nUsage:\n" +
                    "	Scenario.Tools.Executor <WorkflowName> [NrExecution]\n\n" +
                    "This program invokes criteria workflow engine and execute <WorkflowName>\n" +
                    "Options:\n" +
                    "	NrExecution		the number of process execution. Default is 1\n");
	        }

            int iNrWorkflow = 1;
            if (args.Length == 2)
            {
                iNrWorkflow = Int32.Parse(args[1]);
            }

            Engine engine = null;
            engine = Engine.Instance;
            
            engine.StartUp(String.Empty, false);

            for (int i = 0; i < iNrWorkflow; i++)
            {
                String processID = Engine.ProcessHelper.StartWorkflow(args[0], null, true);

                System.Console.WriteLine("Nr[{0}]: Eseguito processo{1}", i + 1, processID);
            }

            engine.ShutDown();
            
        }

    }
}
